import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:墨琦
 * Data:2023-03-22
 * Time:13:51
 */
public class Text1 {
    public static void main(String[] args) {
       ArrayList<Dog> ml=new ArrayList<Dog>();
       Scanner sc=new Scanner(System.in);
        System.out.println("需要存储狗数目：");
       int k=sc.nextInt();

       int age=0;String name=null;
       for(int i=0;i<k;i++) {
           Dog kk=new Dog();
           System.out.print("狗的名字和年龄：");
            name=sc.next();
            age=sc.nextInt();
           System.out.print("\n");
           kk.setAge(age);
           kk.setBread(name);
           ml.add(i,kk);
       }
        System.out.println("查询总数："+ml.size());
        System.out.println("狗的名单：\n品种   年龄");
       for(Dog tt:ml)
       {
           System.out.println(tt.getBread()+"   "+tt.getAge());
       }
        System.out.println("删除的品种：");
       String names=sc.next();
        for(int c1=0;c1<k-1;c1++) {
            if (((ml.get(c1)).getBread()).equals(names))
            {
                ml.remove(c1);
                System.out.println("删除成功");
            }
        }
        Iterator fw=ml.iterator();
        while(fw.hasNext())
        {
            Dog tt=(Dog) fw.next();
            System.out.println("狗种类："+"  "+"狗年龄");
            System.out.println(tt.getBread()+"  "+tt.getAge());
        }
        LinkedList<Dog> list=new LinkedList<Dog>();
        for(int c1=0;c1<k-1;c1++) {
            list.add(ml.get(c1));
        }
    }
}

class Dog{
    private String bread;
    private int age;
    Dog()
    {}

    public String getBread() {
        return bread;
    }

    public void setBread(String bread) {
        this.bread = bread;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
